﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class Disposition : System.Web.UI.UserControl
{

    //public static string connString = "user id=portaluser;data source=172.25.9.26;initial catalog=VoiceNet_Focus;password=sqluser";

    //public SqlConnection conn = new SqlConnection(connString);

    protected void Page_Load(object sender, EventArgs e)
    {

        Response.Expires = -1;


        if (!IsPostBack)
        {
            try
            {
                System.Data.DataTable temp = ((DataAccess)Session["App"]).GetAllUsercodes();
                //ddlDispo.DataSource = temp;
                //ddlDispo.DataTextField = temp.Columns["textField"].ColumnName.ToString();
                //ddlDispo.DataValueField = temp.Columns["usercode"].ColumnName.ToString();
                foreach (System.Data.DataRow r in temp.Rows)
                {
                    if (r["Disposition"].ToString() == "SC")
                    {
                        ddlDispo.Items.Add(new ListItem(r["textField"].ToString(), r["usercode"].ToString()));
                    }
                }
                //ddlDispo.DataBind();
                ddlDispo.Items.Insert(0, new ListItem("Select a Sale Dispo", ""));
            }
            catch
            {
                ddlDispo.Items.Insert(0, new ListItem("Unable to get dispos", "Unable to get dispos"));
            }
        }
        else
        {

        }

    }

    //protected void Page_Unload(
    protected void ddlDispo_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            ((DataAccess)Session["App"]).PutCallData("webusercode", ddlDispo.SelectedItem.Value);
            ((DataAccess)Session["App"]).CommitCallData();
        }
        catch
        {
        }
    }
}